﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Titan.Core;

namespace Titan.EntityOperationMonitor
{
    public class ConsoleEntityOperationMonitor : IEntityOperationMonitor
    {
        public void OnOperate(IDbSession session, Operation operation)
        {
            if (operation == null) return;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("EntityType:{0}\tOperation:{1}", operation.EntityType, operation.OperationType);

            if (operation.Key != null)
            {
                sb.Append("\tkeys:");
                foreach (KeyValuePair<string, object> kv in operation.Key)
                {
                    sb.AppendFormat("{0}={1},",kv.Key,kv.Value);
                }
            } 

            Console.WriteLine(sb.ToString());
        }
         
    }
}
